
<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="UTF-8">
    <link href="/static/devtools30/layui/css/layui.css" rel="stylesheet" />
    <link href="/static/devtools30/css/devindexbase.css" rel="stylesheet" />
    <script src="/static/devtools30/js/jquery-1.11.2.min.js" type="text/javascript"></script>
    <script src="/static/devtools30/layui/layui.all.js" type="text/javascript"></script>
    <script src="/static/devtools30/js/devtoolCommon.js" type="text/javascript"></script>
    <title>新增功能</title>
    <style>
        /*页面内边距*/
        .addwrap {
            padding: 30px;
        }
        /*按钮组边框*/
        .layui-btn-primary {
            border: 1px solid #C9C9C9!important;
        }
        /*输入框高度*/
        .addwrap .layui-input,
        .layui-select {
            height: 25px;
        }

        .addwrap .layui-input-block {
            min-height: 26px;
            margin-left: 30px;
        }

        .addwrap .layui-form-label {
            padding: 0;
            text-align: right;
            height: 26px;
            line-height: 26px;
            width: 80px;
        }
        .layui-form-radio>i {
            font-size: 17px !important;
        }
        .layui-form-radio {
            line-height: 12px !important;
        }
        .layui-form-radio * {
            font-size: 12px;
        }
        .layui-form-item .layui-form-checkbox[lay-skin=primary] {
            margin-top: 3px !important;
        }
        .layui-form-checkbox span {

            font-size: 12px !important;
        }
        .width120{
            width: 120px;
        }
        .layui-textarea {
            min-height: auto !important;
        }
    </style>
</head>
<body>
<div class="addwrap">
    <di class="layui-form" lay-filter="form" >

        <input type="hidden" name="id" id="id" class="layui-input" th:value="${data.id}">
        <input type="hidden" name="templeid" id="templeid" class="layui-input" th:value="${data.templeid}">
        <div class="layui-form-item flex height26">
            <label class="layui-form-label">序号</label>
            <div class="layui-input-block width120">
                <input  id="xh" name="xh" th:value="${data.xh}" type="number" onkeydown="DigitInput(this)"   required  lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">显示名称</label>
            <div class="layui-input-block width120">
                <input  id="arglable" name="arglable" th:value="${data.arglable}" type="text"   required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">唯一代码</label>
            <div class="layui-input-block width120">
                <input  id="argname" name="argname" th:value="${data.argname}" type="text"   required  lay-verify="required"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item flex height26">

            <label class="layui-form-label">级联控件</label>
            <div class="layui-input-block width120">
                <input  id="jlsrccode" name="jlsrccode" th:value="${data.jlsrccode}" type="text" placeholder="输入级联控件代码"  autocomplete="off" class="layui-input">
            </div>
            <label class="layui-form-label">参数类型</label>
            <div class="layui-input-block width120">
                <select name="cslx" id="cslx" lay-verify="required">
                    <option value="String">String</option>
                    <option value="Number">Number</option>
                </select>
            </div>
            <div class="layui-input-block marginleft10" >
                <input id="isshow" type="checkbox" name="isshow" value="1" th:checked="${data.isshow eq 1} ? 'checked' :'false'" title="显示" lay-skin="primary"  />
            </div>
        </div>
        <div class="flex height26">
            <div class="layui-form-item flex">
                <label class="layui-form-label">控件类型</label>
                <div class="layui-input-block width120">
                    <select name="lx" id="lx" lay-filter="lx" lay-verify="required">
                        <option th:each="c : ${lxList}"  th:value="${c.code}" th:utext="${c.label}">
                        </option>
                    </select>
                </div>
                <label class="layui-form-label">默认数据</label>
                <div class="layui-input-block width120" style="display: none;">
                <select id="dvaluesel" lay-filter="dvaluesel" name="dvaluesel">
                    <option value="">选择默认时间</option>
                    <option value="上年初">上年初</option>
                    <option value="本年初">本年初</option>
                    <option value="本年上季度初">本年上季度初</option>
                    <option value="本年本季度初">本年本季度初</option>
                    <option value="上年本季度初">上年本季度初</option>
                    <option value="本年度上月初">本年度上月初</option>
                    <option value="本年度本月初">本年度本月初</option>
                    <option value="上年度本月初">上年度本月初</option>
                    <option value="上年尾">上年尾</option>
                    <option value="本年尾">本年尾</option>
                    <option value="本年上季度尾">本年上季度尾</option>
                    <option value="本年本季度尾">本年本季度尾</option>
                    <option value="上年本季度尾">上年本季度尾</option>
                    <option value="本年度上月尾">本年度上月尾</option>
                    <option value="本年度本月尾">本年度本月尾</option>
                    <option value="上年度本月尾">上年度本月尾</option>
                    <option value="当前天">当前天</option>
                    <option value="前一天">前一天</option>
                    <option value="后一天">后一天</option>
                </select>
                </div>
                <div class="layui-input-block width120"  style="display: none;">
                <select id="dvaluetpsel" lay-filter="dvaluetpsel" name="dvaluetpsel"   >
                    <option value="">选择时间格式</option>
                    <option value="年">年</option>
                    <option value="月">月</option>
                    <option value="日">日</option>
                    <option value="时">时</option>
                    <option value="分">分</option>
                    <option value="秒">秒</option>
                </select>
                </div>
                <div class="layui-input-block width120">
                    <input  id="dvalue" name="dvalue" th:value="${data.dvalue}" type="text" placeholder=""  autocomplete="off" class="layui-input">
                </div>
            </div>

        </div>


        <div class="layui-form-item layui-form-text flex">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block" style="width: 580px!important;">
                <textarea name="bz" id="bz"  class="layui-textarea">[(${data.bz})]</textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text flex">
            <label class="layui-form-label">控件数据</label>
            <div class="layui-input-block" style="width: 580px!important;">
                <textarea name="lxdata" id="lxdata"  class="layui-textarea">[(${data.lxdata})]</textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text flex">
            <label class="layui-form-label">替换SQL</label>
            <div class="layui-input-block" style="width: 580px!important;">
                <textarea name="tjsql" id="tjsql"  class="layui-textarea">[(${data.tjsql})]</textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text flex">
            <div class="layui-input-block" style="width: 580px!important;">
                注:1、替换的参数格式为#values#,例如条件sql为id='#values#';
                2、当控件数据是查询sql时,在sql前面加上(select) 比如(select)select code value,code label  from sys_staff;
                3、参数可以非必填,当请求为空则表示检索条件不生效,sql参数采用全部替换的方式,查询sql配置为#参数名称#,tjsql配置为 and boolstr = #values#
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block flex flex-jusity-around tjbtn">
                <button class="layui-btn layui-btn-radius layui-btn-sm layui-btn-primary qx" onclick="closeWin()">取消</button>
                <button class="layui-btn layui-btn-radius layui-btn-sm " lay-submit lay-filter="save">保存</button>
            </div>
        </div>
    </di>
</div>
</body>
<script>
    $(function(){
        initEvent();
        selectTimeLx();
    });
    function closeWin(){
        dlCommon.closeParentLayer();
    }

    function initEvent(){
        layui.form.on('submit(save)', function(data){
            saveData();
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });

        $("#lx option[value='[(${data.lx})]']").attr("selected", "selected");
        $("#cslx option[value='[(${data.cslx})]']").attr("selected", "selected");

        layui.form.on('select(dvaluetpsel)', function(data){
            dvaluetpsel();
        });
        layui.form.on('select(dvaluesel)', function(data){
            dvaluesel();
        });
        layui.form.on('select(lx)', function(data){
            selectTimeLx();
        });

        layui.form.render();
    }
    function saveData(){
        var data = layui.form.val('form');
        if(data.isshow==undefined){
            data.isshow=0;
        }

        dlCommon.post("/DevtFormListTemplArgsController/save",data,function(res){
            if(!res.success){
                dlCommon.layerError(res.msg);
                return;
            }
            dlCommon.layerSuccess("保存成功",function(){
                parent.getSearchArgList();
                closeWin();
            })
        },true)
    }
    function selectTimeLx() {
        if($("#lx").val()=="3"){
            var val=$("#dvalue").val();
            if(val.indexOf('#$#')>0){
                $("#dvaluetpsel").val(val.split('#$#')[0]);
                $("#dvaluesel").val(val.split('#$#')[1]);
                layui.form.render();
            }
            $("#dvaluetpsel").parent().show();
            $("#dvaluesel").parent().show();
            $("#dvalue").parent().hide();
        }else{
            $("#dvaluetpsel").parent().hide();
            $("#dvaluesel").parent().hide();
            $("#dvalue").val("");
            $("#dvalue").parent().show();
        }

    }

    function dvaluesel(){
        if($("#dvalue").val()==''){
            $("#dvalue").val('日#$#当前天');
        }
        var value=$("#dvalue").val().split("#$#");
        $("#dvalue").val(value[0]+"#$#"+$("#dvaluesel").val());
    }
    function dvaluetpsel(){
        if($("#dvalue").val()==''){
            $("#dvalue").val('日#$#当前天');
        }
        var value=$("#dvalue").val().split("#$#");
        $("#dvalue").val($("#dvaluetpsel").val()+"#$#"+value[1]);
    }


</script>

</html>